import axios from 'axios'

let url
if (window.location.hostname == '域名') {
  url = ''
} else {
  url = ''
}

export const baseurl = url

const instance = axios.create({
  baseURL: url,
  timeout: 5000,
  headers: {
    'X-Custom-Header': 'foobar'
    // 'Accept': '*/*'
  }
})

// instance.interceptors.request.use((config) => {
//   const { token } = useStore()
//   if (token) {
//     config.headers.Authorization = token
//   }
//   return config
// })
export function post(url, params) {
  return instance.post(url, params).catch((err) => {
    return err
  })
}
export function get(url, params) {
  return instance.get(url, params).catch((err) => {
    return err
  })
}
